package com.test.group6.service.Ipml;

import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.test.group6.domain.WorkesInformation;
import com.test.group6.mapper.AddWorkesMapper;
import com.test.group6.service.AddWorkesService;
import com.test.group6.util.CreateId;
import com.test.group6.util.DateUtil;
@Service
public class AddWorkesServiceIpml implements AddWorkesService{

	private static String IDTYPE_WORKES="Workes";
	@Autowired
	private AddWorkesMapper addWorkesMapper;
	@Override
	public String addNewWorkes(WorkesInformation workesInformation) {
		String id=new CreateId().createId(IDTYPE_WORKES);
		Date registerDate=DateUtil.getRegisterDate();
		workesInformation.setId(id);
		workesInformation.setRegisterDate(registerDate);
		int isSuccess=addWorkesMapper.addNewWorkes(workesInformation);
		String addMessage="";
		if(isSuccess==1){
			addMessage=id;
		}else {
			addMessage="error";
		}
		// TODO Auto-generated method stub
		return addMessage;
	}

}
